<!DOCTYPE html>
<html lang="en" class="no-js">

<head>

    <meta charset="utf-8">
    <title>Fullscreen Login</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- CSS -->
    <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
    <link rel="stylesheet" href="/assets/css/reset.css">
    <link rel="stylesheet" href="/assets/css/supersized.css">
    <link rel="stylesheet" href="/assets/css/style.css">


    <!-- Javascript -->
    <script src="/assets/js/jquery-1.8.2.min.js"></script>
    <script src="/assets/js/supersized.3.2.7.min.js"></script>
    <script src="/assets/js/supersized-init.js"></script>
    <script src="/assets/js/scripts.js"></script>
    <script src="./lib/vue-2.4.0.js"></script>
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

    <![endif]-->

</head>

<body>

<div class="page-container" id="app">
    <h1>学分重修系统</h1>
    <form action="" id="form1" onsubmit="return false;">
        <input type="text" name="username" id="username" class="username" placeholder="Username" v-model="username">
        <input type="password" name="password" id="password" class="password" placeholder="Password" v-model="password">
        <button id="but" @click="search">Sign me in</button>
        <div class="error"><span>+</span></div>
    </form>

</div>


</body>
<script>


    // 创建 Vue 实例，得到 ViewModel
    var vm = new Vue({
        el: '#app',
        data: {
            info: "",
            username: "",
            password: "",
        },

        methods: {
            search() {
                let param = new URLSearchParams()
                param.append('username', this.username),
                param.append('password', this.password),
                    axios({
                        method: 'post',
                        url: 'http://localhost:8080/login',
                        data: param
                    }) .then(function (response) {

                        this.info=response.data
                        if (this.info.code==100){
                            window.location.href="/schoolSchedule.html";
                        }else {
                            alert(this.info.extend.msg)
                        }

                    })
                        .catch(function (error) {
                            console.log(error);
                        });



            },


        }
    });
</script>
</html>

